<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    {% load static %}
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>异常管理</title>
    <link rel="stylesheet" type="text/css" href="{% static 'css/themes/default/easyui.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'css/themes/icon.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'css/layout.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'css/core.css' %}">
    <script type="text/javascript" src="{% static 'js/jquery.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'js/jquery.easyui.min.js' %}"></script>
    <script type="text/javascript" src="{% static 'js/easyui-lang-zh_CN.js' %}"></script>
    <script type="text/javascript">
		var url;
		function newError(){
			$('#dlg').dialog('open').dialog('setTitle','新增异常');
			$('#fm2').form('clear');
			url = 'save_error';
		}
		function editError(){
			var row = $('#dg').datagrid('getSelected');
			if (row){
				$('#dlg').dialog('open').dialog('setTitle','编辑异常');
				$('#fm2').form('load',row);
				url = 'update_error?id='+row.id;
			}
		}
		function saveError(){
			$('#fm2').form('submit',{
				url: url,
				onSubmit: function(){
					return $(this).form('validate');
				},
				success: function(result){
					var result = eval('('+result+')');
					if (result.success){
						$('#dlg').dialog('close');		// close the dialog
						$('#dg').datagrid('reload');	// reload the user data
					} else {
						$.messager.show({
							title: '错误',
							msg: result.msg
						});
					}
				}
			});
		}

		function removeError(){
			var row = $('#dg').datagrid('getSelected');
			if (row){

				$.messager.confirm('Confirm','确定删除永久删除异常?',function(r){

					if (r){
						$.post('remove_error',{id:row.id},function(result){
							if (result.success){
								$('#dg').datagrid('reload');	// reload the user data
							} else {
								$.messager.show({	// show error message
									title: '错误',
									msg: result.msg
								});
							}
						},'json');
					}
				});
			}
		}


		function check_data(str) {
              var sn= $('#sn').val().trim();
              var device_name=$("#device_name").val().trim();
              var department =$("#department").val().trim();
              var maintence_day =$("#maintence_day").val().trim();
              var maintence_weekend =$("#maintence_weekend").val().trim();
              var maintence_month =$("#maintence_month").val().trim();
              if(sn==""||sn==null)
              {
                //alert("Fill Order Type !");
                $.messager.alert('信息提示','请输入异常机种 !','info');
              }
              else if(device_name==""||device_name==null)
              {
                $.messager.alert('信息提示','请输入异常名称 !','info');
              }
            }

    function find_data() {
        $('#dg').datagrid('load',{
		department: $('#department').val().trim(),
		content: $('#e-content').val().trim(),
		machine: $('#machine').val().trim(),
	});
    }

    </script>

</head>
<body>
<div style="background:#fafafa;padding:10pt 5pt 10pt;">
    <form id="fm" method="post">
        <table style="width:100%;height:auto">
            <tr>
                <td>
                    <!--<a href="#" class="easyui-linkbutton" plain="true" icon="icon-add"
                       onclick="check_data('add')">新增</a>
                    <a href="#" class="easyui-linkbutton" plain="true" icon="icon-remove"
                       onclick="check_data('modify')">修改</a>
                    <a href="#" class="easyui-linkbutton" plain="true" icon="icon-cancel"
                       onclick="check_data('delete')">删除</a>-->
                    <a href="#" class="easyui-linkbutton" plain="true" icon="icon-search" onclick="find_data()">查询</a>
                </td>
                <td><span id="showTip"></span></td>

            </tr>
        </table>
        <hr></hr>
        <table id="tt" style="width:100%;height:auto">
            <tr>
                <td style="border-bottom:1px solid #C0C0C0" width="5%">异常机种:</td>
                <td width="30%"><input type="text" name="machine" id="machine"></input></td>
                <td style="border-bottom:1px solid #C0C0C0" width="5%">异常内容:</td>
                <td width="30%"><input type="text" name="content" id="e-content"></input></td>
                <td style="border-bottom:1px solid #C0C0C0" width="5%">责任部门:</td>
                <td width="30%"><input type="text" name="department" id="department"></input></td>

            </tr>

        </table>
        <hr></hr>


    </form>
    <!-- <table id="tbFind" class="easyui-datagrid" title="My Users" pagination="true" toolbar="#toolbar" >

        <thead>
        <tr>
            <th field="name1" width="25%">工号</th>
            <th field="name2" width="25%">姓名</th>
            <th field="mail" width="25%">邮箱</th>
            <th field="name4" width="25%">联系方式</th>
        </tr>
        </thead>
        <div id="toolbar">
</div>
    </table>
    <div id="toolbar">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="javascript:$('#dg').edatagrid('addRow')">New</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="javascript:$('#dg').edatagrid('destroyRow')">Destroy</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-save" plain="true" onclick="javascript:$('#dg').edatagrid('saveRow')">Save</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-undo" plain="true" onclick="javascript:$('#dg').edatagrid('cancelRow')">Cancel</a>
	</div>
-->
    <table id="dg" title="异常列表" class="easyui-datagrid" style=""
           url="get_error"
           toolbar="#toolbar" pagination="true"
           rownumbers="true" fitColumns="true" singleSelect="true">
        <thead>
        <tr>
            <th field="id" width="50px" data-options="hidden:'true'">id</th>
            <th field="machine" width="50px" sortable="true">异常机种</th>
            <th field="content" width="50px" sortable="true">异常内容</th>
            <th field="department" width="50px" sortable="true">责任部门</th>
            <th field="countermeasure" width="50px" sortable="true">短中长期对策</th>
            <th field="date" width="50px" sortable="true">实际完成日期</th>
            <th field="status" width="50px" sortable="true">状态(结案/未结案)</th>
            <th field="error_time" width="50px" sortable="true">累计异常工时</th>
        </tr>
        </thead>
    </table>
    <div id="toolbar">
        <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newError()">新增异常</a>
        <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editError()">编辑异常</a>
        <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="removeError()">删除异常</a>
    </div>

</div>
<div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
     closed="true" buttons="#dlg-buttons">
    <div class="ftitle">异常信息</div>
    <form id="fm2" method="post" novalidate>
        <div class="fitem">
            <label>异常机种</label>
            <input name="machine" class="easyui-validatebox" required="true">
        </div>
        <div class="fitem">
            <label>异常名称</label>
            <input name="content" class="easyui-validatebox" required="true">
        </div>
        <div class="fitem">
            <label>责任部门</label>
            <input name="department">
        </div>
        <div class="fitem">
            <label>短中长期对策</label>
            <input name="countermeasure" class="easyui-textbox"  data-options="multiline:true" style="width:300px;height:100px">
        </div>
        <div class="fitem">
            <label>实际完成日期</label>
            <input name="date" class=" easyui-datebox" >
        </div>
        <div class="fitem">
            <label>状态(结案、未结案)</label>
            <select class="easyui-combobox" name="status" id="status" style="width:200px;">
                    <option selected="selected" disabled="disabled"  style='display: none' value=''></option>
                <option value='结案'>结案</option>
                <option value='未结案'>未结案</option>
            </select>
        </div>
        <div class="fitem">
            <label>累计异常工时</label>
            <input name="error_time" class="easyui-textbox" >
        </div>
    </form>
</div>
<div id="dlg-buttons">
    <a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveError()">保存</a>
    <a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>

</div>
</body>


</html>